package org.millioncall.yueyoga.admin.service.impl;

import java.util.List;
import java.util.Map;

import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.yueyoga.admin.dao.AreaDAO;
import org.millioncall.yueyoga.admin.model.Area;
import org.millioncall.yueyoga.admin.service.AreaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class AreaServiceImpl implements AreaService {
	private static final Logger logger = LoggerFactory.getLogger(Area.class);

	private AreaDAO areaDAO;

	public AreaDAO getAreaDAO() {
		return areaDAO;
	}

	public void setAreaDAO(AreaDAO areaDAO) {
		this.areaDAO = areaDAO;
	}

	@Override
	public PaginatedList<Area> getAreaInPage(int start, int pageSize) {
		PaginatedList<Area> p=areaDAO.findPage(start,pageSize);
		return p;
	}

	@Override
	public boolean savearea(Map<String, Object> map) {
		int i=areaDAO.save(map);
		if(i>0){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public boolean updatearea(Map<String, Object> map) {
		int i=areaDAO.update(map);
		if(i>0){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public void deleteareaByIds(Integer[] deids) {
		if(deids == null || deids.length == 0) {
			logger.error("未提交要删除演讲者的编号");
			throw new RuntimeException(" 未提交要删除演讲者的编号");
		} else {
			this.areaDAO.deleteByIds(deids);
		}
	}

	@Override
	public PaginatedList<Area> getAreaInPage(int start, int pageSize,
			Map<String, Object> map) {
		PaginatedList<Area> p=areaDAO.findPage(start,pageSize,map);
		return p;
	}

	@Override
	public List<Area> getAreaInPage(Map<String, Object> map) {
		List<Area> p=areaDAO.findPage(map);
		return p;
	}

	@Override
	public List<Area> getAreaInPage() {
		List<Area> p=areaDAO.findPage();
		return p;
	}

	@Override
	public List<Area> findAreaByAreaId(Map<String, Object> map) {
		List<Area> p=areaDAO.findAreaByAreaId(map);
		return p;
	}

	@Override
	public Area getAreaByAreaId(Integer id) {
		// TODO Auto-generated method stub
		return areaDAO.findAreaById(id);
	}
	
}
